import http from "@/utils/http";

export const loginAPI = (username: string, password: string) => {
  return http({
    url: "/model/admin/login",
    method: "POST",
    params: {
      username,
      password,
    },
  });
};

export const getProfileAPI = () => {
  return http({
    url: "/model/admin/getInfo",
    method: "GET",
  });
};

export const modifyProfileAPI = (
  id: number,
  username: string,
  password: string
) => {
  return http({
    url: "/model/admin/editInfo",
    method: "POST",
    data: {
      id,
      username,
      password,
    },
  });
};

export const uploadImageAPI = (data: FormData) => {
  return http({
    url: "/model/admin/upload",
    method: "POST",
    data,
  });
};

export const addModelAPI = (data: {
  id: number;
  inTown: number;
  name: string;
  headImage: string;
  sex: number;
  height: string;
  bust: string;
  waist: string;
  hips: string;
  hair: string;
  eyes: string;
  shoes: string;
}) => {
  return http({
    url: "/model/admin/add",
    method: "POST",
    data,
  });
};

export const editModelAPI = (data: {
  id: number;
  inTown: number;
  name: string;
  headImage: string;
  sex: number;
  height: string;
  bust: string;
  waist: string;
  hips: string;
  hair: string;
  eyes: string;
  shoes: string;
}) => {
  return http({
    url: "/model/admin/edit",
    method: "POST",
    data,
  });
};

export const addImagesAPI = (id: number, imageUrl: string) => {
  return http({
    url: "/model/admin/addImages/" + id,
    method: "POST",
    params: {
      imageUrl,
    },
  });
};

export const deleteImagesAPI = (id: number) => {
  return http({
    url: "/model/admin/deleteImage/" + id,
    method: "DELETE",
  });
};

export const deleteModelAPI = (id: number) => {
  return http({
    url: "/model/admin/delete/" + id,
    method: "DELETE",
  });
};

export const searchAllFemaleModelAPI = (
  page: number,
  pageSize: number,
  name: string
) => {
  return http({
    url: "/model/admin/women",
    method: "GET",
    params: {
      page,
      pageSize,
      name,
    },
  });
};

export const searchAllMaleModelAPI = (
  page: number,
  pageSize: number,
  name: string
) => {
  return http({
    url: "/model/admin/men",
    method: "GET",
    params: {
      page,
      pageSize,
      name,
    },
  });
};

export const searchAllInTownModelAPI = (
  page: number,
  pageSize: number,
  name: string
) => {
  return http({
    url: "/model/admin/inTown",
    method: "GET",
    params: {
      page,
      pageSize,
      name,
    },
  });
};

export const showHomeAPI = () => {
  return http({
    url: "/model/admin/getHome",
    method: "GET",
  });
};

export const addHomeAPI = (imageUrl: string) => {
  return http({
    url: "/model/admin/addHome",
    method: "POST",
    params: {
      imageUrl,
    },
  });
};

export const deleteHomeAPI = (id: number) => {
  return http({
    url: "/model/admin/deleteHome/" + id,
    method: "DELETE",
  });
};

export const searchModelImagesAPI = (id: number) => {
  return http({
    url: "/model/admin/getAllImages/" + id,
    method: "GET",
  });
};
